package com.itheima.thread;

import java.io.*;
import java.net.Socket;

//UUID
public class ClientDemo01 {
    public static void main(String[] args) throws IOException {
       // Socket socket = new Socket("192.168.12.217",8888);
        Socket socket = new Socket("127.0.0.1",10086);

        //创建本地输入流，将本地文件读到内存中
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day15_inter\\aaa.png"));

        //创建网络输出流
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);
        int b ;
        //循环读取本地数据在发送出去
        while ((b = bis.read())!=-1){
            bos.write(b);
        }

        bis.close();
        //将输出流停止，但没有关闭
        socket.shutdownOutput();


        //接收反馈
        InputStream is = socket.getInputStream();
        BufferedReader jieshou  = new BufferedReader(new InputStreamReader(is));
        String s;
        while ((s = jieshou.readLine())!=null){
            System.out.println(s);
        }
        jieshou.close();
        socket.close();
    }
}
